{extend name='admin@public/content'}

{block name="content"}

<style>
    #amap{height: 500px}
</style>
<form autocomplete="off" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='form-horizontal layui-form padding-top-20'>

    <div class="form-group">
        <label class="col-sm-2 control-label">商家名称</label>
        <div class='col-sm-8'>
            <input autofocus name="store_name" value='{$vo.store_name|default=""}' required="required" title="商家名称" placeholder="商家名称" class="layui-input">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">商家地址</label>
        <div class='col-sm-3'>
            <input id="addressmap" name="store_address" value='{$vo.store_address|default=""}' required="required" title="商家地址" placeholder="商家地址" class="layui-input">
        </div>
        <div class='col-sm-6' id="amap"></div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">所属会员</label>
        <div class='col-sm-8'>
            <select name='store_uid' class='layui-select full-width' lay-ignore>
                <option selected value='0'>---请选择---</option>
                <!--{foreach $members as $menu}-->
                <!--{eq name='menu.id' value='$vo.store_uid|default=0'}-->
                <option selected value='{$menu.id}'>{$menu.username}-{$menu.nickname}</option>
                <!--{else}-->
                <option value='{$menu.id}'>{$menu.username}-{$menu.nickname}</option>
                <!--{/eq}-->
                <!--{/foreach}-->
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">所属行业</label>
        <div class='col-sm-8'>
            <select name='store_cate' class='layui-select full-width' lay-ignore>
                <option selected value='0'>---请选择---</option>
                <!--{foreach $data as $menu}-->
                <!--{eq name='menu.id' value='$vo.store_cate|default=0'}-->
                <option selected value='{$menu.id}'>{$menu.title}</option>
                <!--{else}-->
                <option value='{$menu.id}'>{$menu.title}</option>
                <!--{/eq}-->
                <!--{/foreach}-->
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">法人姓名</label>
        <div class='col-sm-8'>
            <input name="store_f_name" value='{$vo.store_f_name|default=""}'  class="layui-input">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">联系电话</label>
        <div class='col-sm-8'>
            <input name="store_mobile" value='{$vo.store_mobile|default="暂无号码"}' class="layui-input">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">座机号码</label>
        <div class='col-sm-8'>
            <input autofocus value='{$vo.store_phone|default=""}' class="layui-input">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label label-required">身份证正反面</label>
        <div class='col-sm-8'>
            <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                <thead>
                <tr>
                    <td>图片</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td class="text-top">
                        <input type="hidden" name="store_card_image" value="{$vo.store_card_image|default=''}">
                        <script>$('[name=store_card_image]').uploadMultipleImage()</script>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label label-required">商家环境图片</label>
        <div class='col-sm-8'>
            <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                <thead>
                <tr>
                    <td>图片</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td class="text-top">
                        <input type="hidden" name="store_images" value="{$vo.store_images|default=''}">
                        <script>$('[name=store_images]').uploadMultipleImage()</script>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="hr-line-dashed"></div>

    <div class="col-sm-7 col-sm-offset-2">
        <div class="layui-form-item text-center">
            {if !empty($vo.id)}<input type="hidden" name="id" value="{$vo.id}">{/if}
            <button class="layui-btn" type="submit">保存配置</button>
            <button class="layui-btn layui-btn-danger" type='button' onclick="window.history.back()">取消编辑</button>
        </div>
    </div>

    <script>window.form.render();</script>
    <script type="text/javascript">
        function map_init(e) {
// 百度地图API功能

            let that = this;

            var map = new BMap.Map("amap");

            map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);

// 添加带有定位的导航控件

            var navigationControl = new BMap.NavigationControl({

// 靠左上角位置

                anchor: BMAP_ANCHOR_TOP_LEFT,

// LARGE类型

                type: BMAP_NAVIGATION_CONTROL_LARGE,

// 启用显示定位

                enableGeolocation: true

            });

            map.addControl(navigationControl);

            map.enableScrollWheelZoom(true);

            map.enableInertialDragging();

            map.enableContinuousZoom();

            var geoc = new BMap.Geocoder();



            function showInfo(e) {
                layPoint(e);

                geoc.getLocation(e.point, function (rs) {
                    var addComp = rs.address + rs.surroundingPois[0].title;
                    //let address = addComp.province + addComp.city + addComp.district + addComp.street +addComp.streetNumber;
                    document.getElementById('addressmap').value=addComp;

                });

            }

// 创建地址解析器实例

            var myGeo = new BMap.Geocoder();

// 将地址解析结果显示在地图上,并调整地图视野
            myGeo.getPoint(e, function (point) {

                if (point) {

                    map.centerAndZoom(point, 16);

                    map.addOverlay(new BMap.Marker(point));

                } else {

                    alert("您选择地址没有解析到结果!");

                }

            }, e);

// 添加挑中的点

            function layPoint(e) {

// 清楚点

                map.clearOverlays();

// 添加点

                var point = new BMap.Point(e.point.lng, e.point.lat);

                map.centerAndZoom(point, 15);

                var marker = new BMap.Marker(point); // 创建标注

                map.addOverlay(marker); // 将标注添加到地图中

                marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动

            }

            map.addEventListener("click", showInfo);

        }

        map_init('贵阳市')
    </script>
</form>
{/block}